﻿@model IEnumerable<ManageOrganizationsItemViewModel>

@if (!Model.Any())
{
    <p>This account is not a member of any organizations.</p>

    return;
}

<div class="row user-package-list align-left">
    <div class="col-md-12 align-left ">
        <div class="panel-collapse collapse in" id="organizations-list" aria-expanded="true">
            <div class="list-packages" role="list">
                <table class="table align-left">
                    <thead>
                        <tr class="manage-package-headings">
                            <th class="hidden-xs"></th>
                            <th class="hidden-xs"></th>
                            <th>Organization</th>
                            <th>Membership</th>
                            <th>Members</th>
                            <th>Packages</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var organization in Model)
                        {
                            <tr class="manage-package-listing">
                                <td class="align-middle ">
                                    @if (organization.MemberCount == 1)
                                    {
                                        <i class="ms-Icon ms-Icon--StatusErrorFull red-check" title="After account delete the organization will not have any members."></i>
                                    }
                                    else
                                    {
                                        <i class="ms-Icon ms-Icon--CompletedSolid green-check" title="After account delete the organization will still have at least one member."></i>
                                    }
                                </td>
                                <td class="align-middle hidden-xs">
                                    <img src="@GravatarHelper.Url(Url, organization.EmailAddress, organization.OrganizationName, 256)" class="package-icon img-responsive" aria-hidden="true" alt="" />
                                </td>
                                <td class="align-middle package-id">
                                    <a title="View Organization Profile" href="@Url.User(organization.OrganizationName)">
                                        @organization.OrganizationName
                                    </a>
                                    @if (organization.IsPendingRequest)
                                    {
                                        <span>(pending approval)</span>
                                    }
                                </td>
                                <td class="align-middle">
                                    @(organization.CurrentUserIsAdmin ? "Administrator" : "Collaborator")
                                </td>
                                <td class="align-middle text-nowrap">
                                    @organization.MemberCount
                                </td>
                                <td class="align-middle text-nowrap">
                                    @organization.PackagesCount
                                </td>
                                <td class="text-right align-middle package-controls">
                                    <a class="btn" href="@Url.ManageMyOrganization(organization.OrganizationName)" title="Edit Organization" aria-label="@("Edit Organization " + organization.OrganizationName)">
                                        <i class="ms-Icon ms-Icon--Edit" aria-hidden="true"></i>
                                    </a>
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>